package user;

import java.util.HashMap;
import java.util.Map;

/**
 * An enumeration representing user privilege levels.
 * It associates each level to an int for easy comparisons
 * @author Enrique De Diego
 *
 */
public enum UserPrivilege 
{
	ADMIN(1), 
	COACH(2),
	ATHLETE(3), 
	FAN(4);
	
	private int level;
	
	UserPrivilege( int level )
	{
		this.level = level;
	}
	
	public int getLevel()
	{
		return level;
	}
	
	public static UserPrivilege convertIntToPriv(int level)
	{
		Map<Integer, UserPrivilege> m = new HashMap<Integer, UserPrivilege>();
		m.put(1, UserPrivilege.ADMIN);
		m.put(2, UserPrivilege.COACH);
		m.put(3, UserPrivilege.ATHLETE);
		m.put(4, UserPrivilege.FAN);
		return m.get(level);
	}
	
	
}
